<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 伪类选择器 </title>
    <style>
        .box p:first-child{
            color: red;
        }
        .box p:last-child{
            color: blue;
        }
        .box p:nth-child(5){
            color: green;
        }
        .box p:nth-child(even){
            background-color: #ccc;
        }
        .box p:nth-child(odd){
            background-color: #aaa;
        }
    </style>
</head>
<body>
    
    <div class="box">
        <p>段落1</p>
        <p>段落2</p>
        <p>段落3</p>
        <p>段落4</p>
        <p>段落5</p>
        <p>段落6</p>
        <p>段落7</p>
    </div>
</body>
</html>